package com.niit.controller;

import org.springframework.stereotype.Controller;

@Controller("/user")
public class ViewController {
/*
    @Autowired
    UserService userService;

    @RequestMapping("/Login")
    public String Login(){
        return "Login";
    }

    @PostMapping("/Login.do")
    public String doLogin(@RequestParam String username,
                          @RequestParam String password){
        //查询方法
        Result result = userService.doLogin(username,password);

        //判断
        if (result.getData()!=null){
            System.out.println("登陆成功");
            return "Admin_index";
        } else{
            System.out.println("登陆失败");
            return "Error";
        }

    }
    @RequestMapping("/register")
    public String register(){
        return "register";
    }
    @PostMapping("/register.do")
    public String register(@RequestParam String username,@RequestParam String email,
                         @RequestParam String password){
        Result result = new Result();
        result =userService.queryByUsername(username);
        if (result.getData()!=null){
            System.out.println("该用户已经注册过了，请重新注册");
            return "register";
        }else {
            User user = new User();
            user.setUsername(username);
            user.setPassword(password);
            user.setEmail(email);
            result =userService.insert(user);
            System.out.println("注册成功");
            return "index";
        }

    }*/
}
